import sys
import cx_Oracle

def file_len(full_path):
	f = open(full_path)
	nr_of_lines = sum(1 for line in f)
	f.close()
	return nr_of_lines

con = cx_Oracle.connect("dataguard","dataguard","dataguard")
cursor = con.cursor()
beginDate = sys.argv[1]
bindVar = {'arg1':beginDate}
sql = "select count(*) from sjsfx where fxfsrq = to_date(:arg1,'yyyy-mm-dd')"

cursor.execute(sql,bindVar)
row = cursor.fetchall()
cursor.close()
con.close()
fx_db_count = row[0][0]

file_name = "d:/cdwtest/jysj/%s/sjsfx.csv" % beginDate
csv_count = file_len(file_name)

count_diff = fx_db_count - csv_count

sys.stdout.write(str(count_diff))

